﻿using System;
using System.Windows.Forms;
using WinFormSQLServerLoginDemo.Entity;
using WinFormSQLServerLoginDemo.Services;

namespace WinFormSQLServerLoginDemo
{
    public partial class LoginForm : Form
    {
        private UserService userService;

        public LoginForm()
        {
            InitializeComponent();
            userService = new UserService();
        }

        private void LoginBtn_Click(object sender, EventArgs e)
        {
            string username = UsernameTextBox.Text;
            string password = PasswordTextBox.Text;
            User user = userService.Login(username, password);
            if (user == null)
            {
                MessageBox.Show("账号或密码错误！");
                return;
            }
            MessageBox.Show("登录成功！");
        }
    }
}
